<?php
/**
 * @author GhostWei
 * @date Oct 15, 2012
 */
class system_nav_advertise {

	protected $_hash = null;
	protected $_name = null;
	public function __construct($name = null) {
		$this->_name = $name;
		$this->_hash = spl_object_hash($this);
	}
	
	public function add() {
		system_nav_crumbs::getInstance()->addAdvertise($this);
		return $this;
	}
	
	public function getHash() {
		return $this->_hash;
	}
	
	public function getName() {
		return $this->_name;
	}
	
	protected $_script = array();
	/**
	 * @return system_nav_advertise
	 */
	public function setScript($src) {
		$this->_script = $this->strToArray($src);
		return $this;
	}
	public function getScript() {
		return $this->_script;
	}
	
	protected $_scriptBody = null;
	/**
	 * @return system_nav_advertise
	 */
	public function setScriptBody($body) {
		$this->_scriptBody = $body;
		return $this;
	}
	public function getScriptBody() {
		return $this->_scriptBody;
	}
	
	protected $_style = array();
	/**
	 * @return system_nav_advertise
	 */
	public function setStyle($src) {
		$this->_style = $this->strToArray($src);
		return $this;
	}
	public function getStyle() {
		return $this->_style;
	}
	
	protected function strToArray($src) {
		$result = array();
		$src = preg_replace('/[\r\n]+/', '\n', trim($src));
		foreach(explode('\n', $src) AS $v) {
			if(1 && $v = trim($v)) {
				$result[md5($v)] = $v;
			}
		}
		return $result;
	}
	
	protected $_styleBody = null;
	/**
	 * @return system_nav_advertise
	 */
	public function setStyleBody($body) {
		$this->_styleBody = $body;
		return $this;
	}
	public function getStyleBody() {
		return $this->_styleBody;
	}
	
	protected $_resource = null;
	/**
	 * @return system_nav_advertise
	 */
	public function setResource($resource) {
		$this->_resource = $resource;
		return $this;
	}
	public function getResource() {
		return $this->_resource;
	}
	
	protected $_isLayout = true;
	/**
	 * @return system_nav_advertise
	 */
	public function setIsLayout($is) {
		$this->_isLayout = $is;
		return $this;
	}
	public function getIsLayout() {
		return $this->_isLayout;
	}
	
	protected $_url = null;
	/**
	 * @return system_nav_advertise
	 */
	public function setUrl($url) {
		$this->_url = $url;
		return $this;
	}
	public function getUrl() {
		return $this->_url;
	}
	
	protected $_width = 0;
	/**
	 * @return system_nav_advertise
	 */
	public function setWidth($width) {
		$this->_width = $width;
		return $this;
	}
	public function getWidth() {
		return $this->_width;
	}

	protected $_height = 0;
	/**
	 * @return system_nav_advertise
	 */
	public function setHeight($height) {
		$this->_height = $height;
		return $this;
	}
	public function getHeight() {
		return $this->_height;
	}
		
}